package com.szbmyoubao.app.view.dialog

import android.app.Activity
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import com.ellecity06.common.R
import com.ellecity06.common.base.BaseDialog
import com.ellecity06.cwhiskymall.databinding.DialogBottomShareBinding

/**
 * @author ellecity06
 * @time 2024/12/25 18:07
 * @des
 */

class ShareDialog(
    private val activity: Activity,
    private val onShare: OnShareCallBack? = null,
) : BaseDialog<DialogBottomShareBinding>(activity), View.OnClickListener {
    override val animation: Int
        get() = R.style.Animation_Design_BottomSheetDialog
    override val gravity: Int
        get() = Gravity.BOTTOM
    override val widthP: Float
        get() = 1F

    override fun inflaterViewBinding(): DialogBottomShareBinding {
        return DialogBottomShareBinding.inflate(LayoutInflater.from(activity))
    }

    override fun initialize() {
        binding.layoutWx.setOnClickListener(this)
        binding.layoutFirend.setOnClickListener(this)
        binding.layoutCopy.setOnClickListener(this)
    }

    abstract class OnShareCallBack {
        open fun onWechat() {}
        open fun onFriends() {}
        open fun onCopy() {}
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            binding.layoutWx.id -> {
                onShare?.onWechat()
                dismiss()
            }

            binding.layoutFirend.id -> {
                onShare?.onFriends()
                dismiss()
            }

            binding.layoutCopy.id -> {
                onShare?.onCopy()
                dismiss()
            }
        }
    }
}